package com.edu.aop;

import com.edu.handler.LogHandler;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;

import java.lang.reflect.Proxy;

/**
 * @Author:zyn
 * @Date:2025/11/11--10:43:39
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
//    @Override
//    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
//        return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
//    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("执行了bean后处理器后置处理");
        Object proxy= Proxy.newProxyInstance(bean.getClass().getClassLoader(), bean.getClass().getInterfaces(),new LogHandler(bean));
        return proxy;
    }
}
